package com.course.android.ui.adapter;

import android.view.View;

import com.baselib.android.utils.ToastTool;
import com.baselib.android.utils.img.ImageLoader;
import com.baselib.android.view.BaseRAadapter;
import com.course.android.R;
import com.course.android.activity.ActivityIntent;
import com.course.android.ui.adapter_holder.WebNewsHolder;
import com.course.model.resp.NewsVo;

public class WebNewsAdapter  extends BaseRAadapter<NewsVo, WebNewsHolder> {


    @Override
    protected WebNewsHolder creatHolder(View view) {
        return new WebNewsHolder(view);
    }

    @Override
    protected int getLayoutId(int position) {
        return R.layout.adapter_web_news;
    }

    @Override
    protected void bindData(int position, NewsVo item, WebNewsHolder holder) {
        holder.titleTv.setText(item.getTitle());
        holder.descTv.setText(item.getDesc());
        ImageLoader.getInstance(holder.itemView.getContext()).displayImage(item.getImg(),holder.iv);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToastTool.show(holder.itemView.getContext(),item.getUrl());
                ActivityIntent.toWebViewIntent(holder.itemView.getContext(),item.getTitle(),item.getUrl());
            }
        });
    }
}
